/**
 * 
 */
package bancosys.tec.security;

import java.io.IOException;
import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;

import jmine.tec.utils.collection.ClasspathPropertiesLoader;

/**
 * Configura algumas URLs relativas a seguranca
 * 
 * @author takeshi
 */
public final class SecurityURLMapping implements Serializable {

    private final transient Map<String, String> map = new HashMap<String, String>();

    private static final SecurityURLMapping INSTANCE = new SecurityURLMapping();

    /**
     * Returns the new instance
     * 
     * @return {@link SecurityURLMapping}
     */
    public static SecurityURLMapping getInstance() {
        return INSTANCE;
    }

    /**
     * Constructor
     */
    private SecurityURLMapping() {
        try {
            map.putAll(new ClasspathPropertiesLoader("security.properties").getProperties());
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    /**
     * @return the logout URL or <code>null</code>
     */
    public String getLogoutURL() {
        return map.get("logout");
    }

    /**
     * @return the unauthorized URL or <code>null</code>]
     */
    public String getUnauthorizedURL() {
        return map.get("unauthorized");
    }

    /**
     * @return the login URL or <code>null</code>
     */
    public String getLoginURL() {
        return map.get("login");
    }

    /**
     * @return Object
     */
    private Object readResolve() {
        return INSTANCE;
    }
}